<?php

class Footermenu_Model_Collection extends Core_Model_Item_Abstract {
	public function removeAllAssoc($id) {
		
		$table = Engine_Api::_ ()->getDbtable ( 'categories', 'footermenu' );
		$TableName = $table->info ( 'name' );
		$select = $table->select ()->where ( "{$TableName}.cid  = ?", $id );
		$categories = $table->fetchAll ( $select );
		
		Engine_Api::_ ()->getDbtable ( 'categories', 'footermenu' )->delete ( array ('cid = ?' => $id ) );
		
		foreach ( $categories as $category ) {
			Engine_Api::_ ()->getDbtable ( 'references', 'footermenu' )->delete ( array ('cat_id = ?' => $category ['category_id'] ) );
		}
		return $this;
	}
}
